<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div th:fragment="nav">
    <!-- 导航栏-->
    <div style="border:2px slateblue solid">
        <h2 align="center">基于SpringBoot2.7.x MyBatis2.3.x Thymeleaf 的学生成绩简易系统-Mark5</h2>
        <hr>
        <div style="display: flex; justify-content: space-between">
            <h4><a href="/mark5/go2login">学生成绩简易系统-首页</a></h4>
            <div  style="width: 50%; display: flex;  align-content: right;  justify-content: space-between; padding-top: 12px">
                <p th:if="${ session.user== null}" style="color: #aabec5">
                    未登录</p>
                <p  th:if="${ session.user!= null}"style="color: orangered">
                    已登录</p>
                <p style="color: blue" >姓名:
                    <span th:if="${session.user!=null}" th:text="${session.user.uname}"></span></p>
                <p style="color: blueviolet">角色:<span th:if="${session.user!=null}" th:text="${session.user.role}"></span></p>

            </div>
            <p style="color: blue"><a href="/mark5/logout.do">退出</a></p>
            <div th:if="${session.user!= null}" style="width: 5vw; height: 5vw">
                <img style="height: 90%; width: 100% " th:src="'/mark5/showimg/'+ ${session.user.pic}"/>
            </div>
            <p>&nbsp;</p>
        </div>
    </div>
    <!--<hr>-->
</div>

<div th:if="${session.user!=null &&session.user.role=='adm'}">
    <div>
  <h2 style="display: flex; justify-content: space-around">学生管理</h2>
    <hr>
    <h3 style="display: flex; justify-content: space-around" th:if="${Session}!=null" th:text="${Session}"></h3>
</div>
<div style="display: flex;justify-content: space-around">
  <div>
      <h2 style="display: flex; justify-content: space-around">学生信息</h2>

      <table  width="120%" border="1" cellspacing="0" style="line-height: 36px">
      <tr>
        <td align="center">Id</td>
        <td align="center"> 姓名</td>
        <td align="center">手机号</td>
        <td align="center">头像</td>
        <td align="center" >班级id</td>
        <td align="center" >班级名</td>
        <td colspan="2" align="center">功能</td>
        <!--align="center" 水平居中-->
      </tr>
      <div th:each="x:${users}">
        <td align="center" th:text="${x.uid}"></td>
        <td align="center" th:text="${x.uname}"></td>
        <td align="center" th:text="${x.phone}"></td>

        <td align="center">
          <div style="width: 10vw; height: 10vw">
          <img style="height: 90%; width: 100% "
               th:src="'/mark5/showimg/'+${x.pic}"/>
          </div>
            <td align="center"  th:text="${x.clz.clzno}"></td>
            <td align="center"  th:text="${x.clz.clzname}"></td>
        <td><a th:href="'/stu/go2update/'+${x.uid}">更改</a></td>
        <td><a th:href="'/stu/del/'+${x.uid}">删除</a></td>

      </tr>
      </div>
    </table>
      <!--翻页-->
      <a th:href="'/stu/prevpage?curpage='+${curpage}">上一页</a>
      <a th:text="(${curpage})"></a> /
      <a th:text="${curpagemax}"></a>
      <a th:href="'/stu/nextpage?curpage='+${curpage}">下一页</a>
  </div>
  <div>
    <h2 style="display: flex; justify-content: space-around">添加与更改</h2>
    <hr>
    <a href="/stu/go2add">添加一位新学生</a>
      <form  th:action="'/stu/'+${action}" method="post"  enctype="multipart/form-data"  >


        <b th:if="${action}=='update'" style="display: flex;
        justify-content: space-around">更改学生</b>

        <b th:if="${action}=='add'"style="display: flex;
        justify-content: space-around">添加学生</b>

          <div th:if="${action}=='update'">
          <p>编号：<input type="text" name="uid" readonly th:value="${uid}"/></p>
          <p>名称：<input type="text" name="uname" th:value="${use.uname}"/></p>
          <p>电话：<input type="text" name="phone" th:value="${use.phone}"/></p>
          <p>密码：<input type="text" name="pwd" th:value="${use.pwd}"/></p>
              班级名称：<select  name="clzno">
              <option th:each="x:${clzs}"
                      th:text="${x.clzname}"
                      th:value="${x.clzno}" th:selected="${x.clzno}==${use.clz.clzno}">
              </option>
          </select>
          <div style="width: 6vw;height: 6vw" >
              <img style="width: 90%;height: 90%" th:src="'/mark5/showimg/'+${use.pic}">
          </div>
          </div>

          <div th:if="${action}=='add'">
              名称:<input type="text" name="uname" ><br>
              密码:<input type="text" name="pwd" ><br>
              电话:<input type="text" name="phone"><br>
              班级:<select name="clzno">
              <option th:each="x:${clzs}"
                      th:text="${x.clzname}"
                      th:value="${x.clzno}">
              </option>
          </select>
            <br>
          </div>
    <input name="img" type="file"/><br>
        <div th:if="${action}=='add'">
          <input type="submit" value="添加">
        </div>
        <div th:if="${action}=='update'">

          <input type="submit" value="修改">
        </div>
    </form>

  </div>

</div>
</div>
</body>
</html>